//
// RS Game Framework
// Copyright © 2010 Jedd Haberstro
// jhaberstro@gmail.com
// 
// $Id:
//

#ifndef RS_GRAPHICS_BUFFER_HPP
#define RS_GRAPHICS_BUFFER_HPP

#include "rs/graphics/GraphicsForwards.hpp"
#include "rs/graphics/Resource.hpp"
#include "rs/graphics/BufferDescription.hpp"

namespace rs
{
    namespace graphics
    {
        class Buffer : public Resource
        {
            RS_DECLARE_POLYMORPHIC_REFLECTION();
            
        public:
            
            virtual void Map(void* data, ResourceAccess::Enum mapType) = 0;
            
            virtual void Unmap() = 0;
            
            virtual void SetData(void* source, UInt32 size, UInt32 offset = 0) = 0;
            
            UInt32 GetSize() const;
                        
            UInt32 GetElementSize() const;
            
        protected:
            
            Buffer(BufferDescription const& description);
            
        protected:
            
            UInt32 count_;
            UInt32 elementSize_;
        };
        
                
        inline Buffer::Buffer(BufferDescription const& description)
        : Resource(description),
          count_(description.GetCount()),
          elementSize_(description.GetElementSize()) {
        }
        
        inline UInt32 Buffer::GetSize() const {
            return count_ * elementSize_;
        }
        
        inline UInt32 Buffer::GetElementSize() const {
            return elementSize_;
        }
    }
}

#endif // RS_GRAPHICS_BUFFER_HPP
